package ynu.edu.Service.Impl;

import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import ynu.edu.Dao.DeviceDao;
import ynu.edu.Dao.NitrogenDao;
import ynu.edu.Entity.Device;
import ynu.edu.Entity.Nitrogen;
import ynu.edu.Service.ISensorService;

import java.util.Date;
import java.util.List;

@Service
public class NitrogenService implements ISensorService {
    @Resource
    DeviceDao deviceDao;
    @Resource
    NitrogenDao nitrogenDao;
    @Override
    public void insert(Double value){
        Nitrogen nitrogen = new Nitrogen();
        Device device = deviceDao.getReferenceById(3L);
        nitrogen.setDevice(device);
        nitrogen.setValue(value);

        nitrogenDao.save(nitrogen);
    }
    @Override
    public Double getValue(){
        Nitrogen nitrogen = nitrogenDao.findFirstByOrderByCreateTimeDesc().get();
        return nitrogen.getValue();
    }
    @Override
    public List<Double> getValuesFromLastDay(){
        return null;
    }
    @Override
    public List<Date> getTimeFromLastDay(){
        return null;
    }
}
